import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;

public class CipherExample {
  // Password must be at least 8 characters
  private static final String password = "la-la-la";


  public static void main(String args[]
  ) throws Exception {

    // Create Key
    SecretKeySpec bfKeySpec = new SecretKeySpec(password.getBytes(), "Blowfish");

    // Create Cipher
    Cipher bfCipher = new NullCipher(); //Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
    bfCipher.init(Cipher.ENCRYPT_MODE, bfKeySpec);

    // Create stream
    FileOutputStream fos =
     new FileOutputStream("out.bf");
    BufferedOutputStream bos =
     new BufferedOutputStream(fos);
    CipherOutputStream cos =
     new CipherOutputStream(bos, bfCipher);
    ObjectOutputStream oos =
     new ObjectOutputStream(cos);


    // Create object
    String name = "myName";

    // Write objects
    oos.writeObject(name);
    oos.flush();
    oos.close();
    /*
    // Change cipher mode
    bfCipher.init(Cipher.DECRYPT_MODE, bfKeySpec);

    // Create stream
    FileInputStream fis =
     new FileInputStream("out.bf");
    BufferedInputStream bis =
    new BufferedInputStream(fis);
    CipherInputStream cis =
    new CipherInputStream(bis, bfCipher);
    ObjectInputStream ois =
     new ObjectInputStream(cis);

    // Read objects
    String unCrName = (String)ois.readObject();
    ois.close();

    // Compare original with what was read back
    int count = 0;
    if (name.equals(unCrName)) {
      System.out.println(" okay.");
      count++;
    }
    if (count != 1) {
      System.out.println(
      "Problem during encryption/decryption");
    }*/
  }
}
